<#include '/admin/header.html' >
<div class="main">
	<div class="input  shadowBoxWhite wf100 whiteBox">
			<input name="showcase_inputAction" id="showcase_inputAction"
				type="hidden" value="${actionName!''}">
			<form method="post" name="theForm" id="theForm" enctype="multipart/form-data">
				<div class="text" style="padding: 20px 15px;">
					<table class="form-table">
						<tbody>
							<th style="text-align: left;" align="left" colspan="2" class="groupname title">基本信息</th>
							<tr>
								<th>标题:</th>
								<td style="text-align: left;"><input
									class="easyui-validatebox input_text validatebox-text validatebox-invalid"
									type="text" maxlength="20" isrequired="true" datatype="string"
									data-options="required:true" name="title" autocomplete="off"
									title=""></td>
							</tr>

							<tr>
								<th>排序:</th>
								<td style="text-align: left;"><input
									class="easyui-validatebox input_text validatebox-text validatebox-invalid"
									type="text" maxlength="5" isrequired="true" datatype="string"
									data-options="required:true" name="sort" autocomplete="off"
									title="" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " value="1">
								橱窗显示的顺序
								</td>

							</tr>

							<tr>
								<th>显示:</th>
								<td style="text-align: left;">
									<input type="radio" name="is_display" value="0" checked="checked">显示
									<input type="radio" name="is_display" value="1">不显示
								</td>
							</tr>
							<tr>
								<th>橱窗标识:</th>
								<td style="text-align: left;"><input
									class="easyui-validatebox input_text validatebox-text validatebox-invalid"
									type="text" maxlength="20" isrequired="true" datatype="string"
									data-options="required:true" name="flag" autocomplete="off"
									title="" onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" value="index_top">
								首页橱窗默认为index_top,如果想增加其他标识请修改对应页面代码,否则页面不显示橱窗
								</td>

							</tr>

							<tr>
								<th style="text-align: left;" align="left" colspan="2" class="groupname title">橱窗内容</th>
								<td style="text-align: left;"><input type="hidden" id="content" name="content"
									value=""></td>
							</tr>

						</tbody>
					</table>
				</div>
			</form>
			<div id="showcase_goods"></div>
			<div class="buttonWrap">
				<a href="javascript:;" id="showcaseinput" class="easyui-linkbutton">确定</a>
			</div>
	</div>
</div>
<script type="text/javascript"
	src="${ctx}/shop/admin/js/jquery.goodsSelector.js">
	
</script>
<script type="text/javascript">
	$(function() {

		//创建商品选择器
		var container = $("#showcase_goods");
		var options = {
			goodsid_name : 'goods_ids',
		};
		container.goodsSelector(options);

		$("#is_display_img").click(function() {
			var dis = $("#is_display").val();
			if (dis == 0) {
				$(this).attr('src', '${ctx}/floor/admin/indexpage/off.jpg');
				$("#is_display").val('1');
			} else if (dis == 1) {
				$(this).attr('src', '${ctx}/floor/admin/indexpage/on.jpg');
				$("#is_display").val('0');
			}
		});

		$("#showcaseinput").click(function() {
			$("#showcaseinput").unbind("click");
			var goods_ids = [];
			$("input[name='goods_ids']").each(function(i, o) {
				goods_ids[i] = $(o).val();
			});
			$("#content").val(goods_ids);
			var disabled = $(this).hasClass("l-btn-disabled");
			if (!disabled) {
				var formflag = $("#theForm").form('validate');
				if (formflag) {
					$("#showcaseinput").linkbutton("disable");
					$.Loading.show("正在保存请稍候..");
					var options = {
						url : $("#showcase_inputAction").val(),
						type : "POST",
						dataType : "json",
						success : function(result) {
							if (result.result == 1) {
								$.Loading.success(result.message);
								parent.SelectTable("橱窗管理");
								parent.refreshCurrentTab();
								parent.CloseTabByTitle("添加橱窗");
							} else {
								$.Loading.error(result.message);
								$("#showcaseinput").linkbutton("enable");
							}
						},
						error : function(e) {
							$.Loading.error("出错了,请重试");
							$("#showcaseinput").linkbutton("enable");
						}
					};
					$('#theForm').ajaxSubmit(options);
				} else {
					$.Loading.error("请检查数据");
				}
			}
		});

	});
</script>

<#include '/admin/footer.html' >
